/*
 * 玫瑰花数（4分）
 */

#include <stdio.h>

int main() {
	setbuf(stdout, NULL);

	int data = 1000, temp, sum = 0;

	while (data <= 9999) {
		temp = data;

		while (temp > 0) {
			sum += ((temp % 10) * (temp % 10) * (temp % 10) * (temp % 10));

			temp /= 10;
		}

		if (sum == data) {
			printf("%d\n", data);
		}

		sum = 0;
		++data;
	}

	return 0;
}
